package com.cndw.kungfu.model.player.domain;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

import com.cndw.kungfu.config.ConstantsConfig;
import com.cndw.kungfu.ext.XmlProcesser;
import com.cndw.kungfu.vo.FavoriteHFVO;

/**
 * 玩家收藏类型
 * @author fantadust
 *
 */
public class Favorite {

	private int id;
	private int sg;
	private int type;
	private int goodsId;
	private String name;
	private int addV;

	public Favorite() {

	}

	private static final String configFile = "favorite.xml";

	private static final Map<Integer, Favorite> officeMap = new ConcurrentHashMap<Integer, Favorite>();

	static {
		load();
	}

	public static synchronized void load() {
		String fileName = ConstantsConfig.getLocaleResource() + configFile;
		List<Favorite> officeList = XmlProcesser.processXml(Favorite.class, fileName);
		for (Favorite e : officeList) {
			officeMap.put(e.getId(), e);
		}
	}
	public static Favorite getOne(int id){
		return officeMap.get(id);
	}
	public static Collection<Favorite> getAll(){
		return officeMap.values();
	}
	@Deprecated
	public static Collection<Favorite> getAllType(int type){
		ArrayList<Favorite> dataList = new ArrayList<Favorite>();
		for (Favorite e : officeMap.values()) {
			if (e.getType() == type) {
				dataList.add(e);
			}
		}
		return dataList;
	}

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public int getType() {
		return type;
	}

	public void setType(int type) {
		this.type = type;
	}

	public int getGoodsId() {
		return goodsId;
	}

	public void setGoodsId(int goodsId) {
		this.goodsId = goodsId;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public int getAddV() {
		return addV;
	}

	public void setAddV(int addV) {
		this.addV = addV;
	}
	public int getSg() {
		return sg;
	}
	public void setSg(int sg) {
		this.sg = sg;
	}
	
	
	public FavoriteHFVO toVOHF(boolean act) {
		return new FavoriteHFVO(this,act);
	}

}
